home *** CD-ROM | disk | FTP | other *** search
/ TeX 1995 July / TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO / macros / latex209 / contrib / misc / chgbar.sty < prev    next >
Text File  |  1993-01-11  |  6KB  |  158 lines

  1. % Change bar document-style option for LaTeX.
  2. %
  3. % Copyright (C) 1990 by David B. Johnson.
  4. %
  5. % dbj@titan.rice.edu (Dave Johnson)
  6.  
  7. % These macros draw a solid bar down the right margin of the output,
  8. % covering a range of the input file that has been declared to be changed.
  9. %
  10. % The beginning and end of a change bar in the text are marked with
  11. % \chgbarbegin and \chgbarend, respectively.  For example,
  12. %
  13. %     Here is some sample text \chgbarbegin that was
  14. %     changed\chgbarend{} and some that wasn't changed.
  15. %
  16. % The change bar is drawn continuously between the line of output
  17. % containing the \chgbarbegin and the line of output containing the
  18. % \chgbarend.  These lines can end up on separate pages, and the
  19. % division at page boundaries is handled automatically.
  20.  
  21. % Two dimensions control the size and placement of the change bars:
  22. %     \chgbarwidth      The width of a change bar
  23. %     \chgbarsep        The distance between the text and the change bar
  24.  
  25. % Warning: it does not appear to be possible to do this completely
  26. % correctly, due to the time at which the verticle glue on a page is
  27. % finally set, and the way that page breaks are decided.  With
  28. % \raggedbottom, this normally works fine.  It hasn't been tested with
  29. % \flushbottom, but will probably behave worse.  In strange rare 
  30. % situations, a change bar might be drawn from the first line of a page
  31. % up off the top of a page; this can usually be fixed by slightly moving
  32. % the \chngbarend around, or by breaking a single change bar range
  33. % into two ranges.
  34.  
  35. \newdimen\chgbarwidth \newdimen\chgbarsep
  36. \chgbarwidth 4pt
  37. \chgbarsep .25in
  38.  
  39. \def\chgbarbegin{\ifhmode\@chgbar{-2}\else\@chgbar{-3}\fi}
  40. \def\chgbarend{\@chgbar{-4}\relax}
  41.  
  42. \marginparpush 0pt
  43.  
  44. % The remainder of this is hacked up based on the LaTeX 2.09 latex.tex.
  45.  
  46. % copied from \marginpar
  47. \def\@chgbar#1{\ifhmode \@bsphack\@floatpenalty -\@Mii\else
  48.    \@floatpenalty-\@Miii\fi\ifinner
  49.       \@parmoderr\@floatpenalty\z@
  50.     \else\@next\@currbox\@freelist{\global
  51.       \count\@currbox#1}{\@floatpenalty\z@ \@fltovf
  52.       \def\@currbox{\@tempboxa}}\fi
  53.      \setbox\@tempboxa\vbox
  54.      \bgroup\end@float\@esphack}
  55.  
  56. \newdimen\@chgbarbegin
  57. \newif\if@inchgbar \@inchgbarfalse
  58.  
  59. \def\@addmarginpar{%
  60. \ifnum\count\@currbox = -2    % change bar begin from hmode
  61.     \global\@chgbarbegin\@pageht \global\advance\@chgbarbegin -\baselineskip
  62.     \global\@inchgbartrue
  63.     \@cons\@freelist\@currbox
  64. \else
  65. \ifnum\count\@currbox = -3    % change bar begin not from hmode
  66.     \global\@chgbarbegin\@pageht
  67.     \global\@inchgbartrue
  68.     \@cons\@freelist\@currbox
  69. \else
  70. \ifnum\count\@currbox = -4    % change bar end
  71.     \if@inchgbar\else\@latexbug\fi
  72.     \@tempdima\@pageht \advance\@tempdima -\@chgbarbegin
  73.     \nointerlineskip
  74.     \@tempcnta\@ne
  75.     \if@twocolumn 
  76.         \if@firstcolumn \@tempcnta\m@ne \fi
  77.     \else 
  78.       \if@mparswitch
  79.          \ifodd\c@page \else\@tempcnta\m@ne \fi
  80.       \fi
  81.       \if@reversemargin \@tempcnta -\@tempcnta \fi
  82.     \fi
  83.     \hbox to\columnwidth
  84.       {\ifnum \@tempcnta >\z@
  85.           \hskip\columnwidth \hskip\chgbarsep
  86.         \else \hskip -\chgbarsep \fi
  87. \hbox{\vbox to 0pt{\vss
  88.        \hrule \@height\@tempdima \@width\chgbarwidth \@depth\z@
  89. }}
  90. \hss}
  91.     \nointerlineskip
  92.     \global\@inchgbarfalse
  93.     \@cons\@freelist\@currbox
  94. \else
  95.     \@next\@marbox\@currlist{\@cons\@freelist\@marbox
  96.     \@cons\@freelist\@currbox}\@latexbug\@tempcnta\@ne
  97.     \if@twocolumn 
  98.         \if@firstcolumn \@tempcnta\m@ne \fi
  99.     \else 
  100.       \if@mparswitch
  101.          \ifodd\c@page \else\@tempcnta\m@ne \fi
  102.       \fi
  103.       \if@reversemargin \@tempcnta -\@tempcnta \fi
  104.     \fi
  105.     \ifnum\@tempcnta <\z@  \global\setbox\@marbox\box\@currbox \fi
  106.     \@tempdima\@mparbottom \advance\@tempdima -\@pageht 
  107.        \advance\@tempdima\ht\@marbox \ifdim\@tempdima >\z@
  108.        \@warning{Marginpar on page \thepage\space moved}\else\@tempdima\z@ \fi
  109.     \global\@mparbottom\@pageht \global\advance\@mparbottom\@tempdima
  110.        \global\advance\@mparbottom\dp\@marbox
  111.        \global\advance\@mparbottom\marginparpush
  112.     \advance\@tempdima -\ht\@marbox
  113.     \global\ht\@marbox\z@ \global\dp\@marbox\z@ 
  114.     \vskip -\@pagedp \vskip\@tempdima\nointerlineskip 
  115.     \hbox to\columnwidth
  116.       {\ifnum \@tempcnta >\z@
  117.           \hskip\columnwidth \hskip\marginparsep
  118.         \else \hskip -\marginparsep \hskip -\marginparwidth \fi
  119.        \box\@marbox \hss}
  120.     \vskip -\@tempdima
  121.     \nointerlineskip
  122.     \hbox{\vrule \@height\z@ \@width\z@ \@depth\@pagedp}
  123. \fi\fi\fi}
  124.  
  125. \def\@makecol{\setbox\@outputbox\box\@cclv
  126.    \if@inchgbar
  127.     \@tempcnta\@ne
  128.     \if@twocolumn 
  129.         \if@firstcolumn \@tempcnta\m@ne \fi
  130.     \else 
  131.       \if@mparswitch
  132.          \ifodd\c@page \else\@tempcnta\m@ne \fi
  133.       \fi
  134.       \if@reversemargin \@tempcnta -\@tempcnta \fi
  135.     \fi
  136.     \@tempdima\ht\@outputbox \advance\@tempdima -\@chgbarbegin
  137.     \advance\@tempdima -\baselineskip
  138.     \setbox\@outputbox
  139.      \vbox{\boxmaxdepth \maxdepth
  140.      \unvbox\@outputbox \nointerlineskip \hbox to\columnwidth
  141.       {\ifnum \@tempcnta >\z@
  142.           \hskip\columnwidth \hskip\chgbarsep
  143.         \else \hskip -\chgbarsep \fi
  144.        \hbox{\vbox to 0pt{\vss
  145.          \hrule \@height\@tempdima \@width\chgbarwidth \@depth\z@}}\hss}}
  146.     \global\@chgbarbegin 0pt
  147. \fi
  148.    \ifvoid\footins\else\setbox\@outputbox
  149.      \vbox{\boxmaxdepth \maxdepth
  150.      \unvbox\@outputbox\vskip\skip\footins\footnoterule\unvbox\footins}\fi
  151.      \xdef\@freelist{\@freelist\@midlist}\gdef\@midlist{}\@combinefloats
  152.      \setbox\@outputbox\vbox to\@colht{\boxmaxdepth\maxdepth
  153.         \@texttop\dimen128=\dp\@outputbox\unvbox\@outputbox
  154.         \vskip-\dimen128\@textbottom}
  155.      \global\maxdepth\@maxdepth}
  156.  
  157. \newenvironment{changebar}{\chgbarbegin}{\chgbarend}
  158.